//
// Labels (aka Switch)
// --------------------------------------------------
// Switch Toggle
// Author: Dominik Dąbrowski
// URL: http://codepen.io/Murkee/pen/mudJx
// mod for LeanCloud by Tunghsiao Liu
//
.switch {
  position: relative;
  margin: 20px 0;
  overflow: auto;
}

.switch-wrap {
  float: right;
  position: relative;
  display: block;
  vertical-align: top;
  width: 40px;
  height: 20px;
  padding: 3px;
  margin-top: -3px;
  background-color: white;
  border-radius: 18px;
  // TODO: this simplfy fixes wrong box behavior in Firefox
  // Ref: https://github.com/leancloud/avfr/issues/381
  // Date: Oct 14, 2015, 4:29 PM
  // Author: Tunghsiao Liu
  box-sizing: content-box !important;
  // box-shadow: inset 0 -1px white, inset 0 1px 1px rgba(0, 0, 0, 0.05);
  cursor: pointer;
  // background-image: linear-gradient(to bottom, #eeeeee, white 25px);
  user-select: none;
}

.switch-text {
  position: absolute;
  top: 0;
  left: 0;
  cursor: pointer;
  right: 46px;
  color: @gray-light;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;

  .switch:hover &,
  .switch:focus & {
    color: @brand-primary;
  }
}

.switch-input {
  position: absolute;
  top: 0;
  right: 0;
  opacity: 0;
}

.switch-label {
  position: relative;
  display: block;
  height: inherit;
  font-size: 10px;
  text-transform: uppercase;
  // background: #eceeef;
  border: 1px solid #ccc;
  border-radius: inherit;
  // box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.12), inset 0 0 2px rgba(0, 0, 0, 0.15);
  transition: 0.15s ease-out;
  transition-property: border-color opacity background;
}
.switch-label:before, .switch-label:after {
  position: absolute;
  top: 50%;
  margin-top: -.5em;
  line-height: 1;
  transition: inherit;
}
.switch-label:before {
  // content: attr(data-off);
  right: 11px;
  color: #aaa;
  text-shadow: 0 1px rgba(255, 255, 255, .5);
}
.switch-label:after {
  // content: attr(data-on);
  left: 11px;
  color: white;
  text-shadow: 0 1px rgba(0, 0, 0, 0.2);
  opacity: 0;
}
.switch-wrap.on .switch-label,
.switch-input:checked ~ .switch-label {
  // background: #47a8d8;
  border-color: @brand-primary;
  // box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.15), inset 0 0 3px rgba(0, 0, 0, 0.2);
}
.switch-wrap.on .switch-label:before,
.switch-input:checked ~ .switch-label:before {
  opacity: 0;
}
.switch-wrap.on .switch-label:after,
.switch-input:checked ~ .switch-label:after {
  opacity: 1;
}

.switch-handle-shadow() {
  box-shadow+: 0 2px 4px fade(#000, 12%);
}

.switch-handle {
  position: absolute;
  top: 5px;
  left: 5px;
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 10px;
  border: 1px solid #ccc;
  .switch-handle-shadow();
  // background-image: linear-gradient(to bottom, white 40%, #f0f0f0);
  transition: 0.15s ease-out;
  transition-property: border-color left background;

  .switch:hover &,
  .switch:focus & {
    border-color: @brand-primary;
    .switch-handle-shadow();
    .form-focus(@brand-primary, 20%, 2px);
  }
}
// .switch-handle:before {
//   content: '';
//   position: absolute;
//   top: 50%;
//   left: 50%;
//   margin: -6px 0 0 -6px;
//   width: 12px;
//   height: 12px;
//   background: #f9f9f9;
//   border-radius: 6px;
//   box-shadow: inset 0 1px rgba(0, 0, 0, 0.02);
//   background-image: linear-gradient(to bottom, #eeeeee, white);
// }
.switch-wrap.on .switch-handle,
.switch-input:checked ~ .switch-handle {
  left: 25px;
  background: @brand-primary;
  border-color: @brand-primary;
  // box-shadow: -1px 1px 5px rgba(0, 0, 0, 0.2);
}

.switch-green > .switch-input:checked ~ .switch-label {
  background: #4fb845;
}
